package com.example.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhangs
 * @version v1.0
 * @decription Servlet2
 * @date 2021/3/23 20:47
 **/
@WebServlet(urlPatterns = "/demo02")
public class Demo02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // 获取到Demo01存储到Request域中的值
        System.out.println("Demo02中获取Demo01中存储的属性" +
                req.getAttribute("name"));
        // 在Request域中存储一个age属性
        req.setAttribute("age", 18);
    }
}
